<style type="text/css">
    [close="0"] td:last-child a
    {
        display: none;
    }

    [close="1"] td, [close="1"] td a
    {
        color: #468847 !important;
        background-color: #dff0d8 !important;
    }
</style>
<?php if ($view->hasExchangeCenters === true): ?>
    <a class="btn btn-primary" href="<?php
    echo $view->url(array(
        'action' => 'add'));
    ?>">
        <span class="glyphicon glyphicon-plus"></span>
        Agregar ruta
    </a>
    <br/>
    <br/>
    <?php if (count($view->routes) == 0): ?>
        <div class="alert alert-info">
            No se encontraron rutas.<br/>Da click en el botón
            <strong>Agregar ruta</strong> y crea una ruta.
        </div>
    <?php else: ?>
        <div class="panel panel-primary" id="rutas">
            <div class="panel-heading">
                <h3 class="panel-title">Rutas</h3>
            </div>
            <?php $view->sc->generatetable($view->routes, ''); ?>
        </div>
    <?php endif; ?>
<?php else: ?>
    <div class='alert alert-info'>
        <p>
            No se encontraron <strong>centros de intercambio vigentes</strong>. 
        </p>
        <p>
            Para poder administrar rutas es necesario crear o activar un <strong>centro 
                de intercambio</strong>.
        </p>
    </div>
    <a class='btn btn-primary' href='<?php
    echo $view->url(array(
        'controller' => 'ExchangeCenters', 'action' => 'Index'));
    ?>'>
        Administración de centros de intercambio
    </a>
<?php endif; ?>
<!-- Modal -->
<div class="modal fade" id="modalDetailRoute" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Resumen de la ruta</h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">Cerrar</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/javascript">
    $(document).ready(function()
    {
        $('#rutas table td').dblclick(function()
        {
            var tr = $(this).parent();
            var id = tr.attr('rid');
            $.post(urlDetailRoute, {id: id}, function(code) {
                $('#modalDetailRoute .modal-body').html(code);
                $('#modalDetailRoute').modal({})
            });
        });
    });
</script>
